package com.lehecai.core.api.event;

import com.lehecai.core.YesNoStatus;
import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.lottery.LotteryType;
import com.lehecai.core.util.CoreDateUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

/**
 *
 */
public class TopPrize extends AbstractApiResultBean {

	public static final String QUERY_ID = "id";
	public static final String QUERY_CREATE_AT = "create_at";
	public static final String QUERY_PRIZE_TIME = "timeline";
	public static final String QUERY_IS_PROFILE = "is_profile";
	public static final String QUERY_TITLE = "title";
	public static final String QUERY_LOTTERY_TYPE = "lottery_type";

	public static final String SET_ID = "id";
	public static final String SET_NAME = "name";
	public static final String SET_USER_PIC = "style";
	public static final String SET_LOTTERY_AGE = "lottery_age";
	public static final String SET_LOTTERY_YTPE = "lottery_type";
	public static final String SET_LOTTERY_LINK = "lottery_link";
	public static final String SET_PLAY_TYPE = "play_type";
	public static final String SET_POST_TAX = "prize_posttax";
	public static final String SET_TIME_LINE = "timeline";
	public static final String SET_AMOUNT = "amount";
	public static final String SET_MULTIPLE = "multiple";
	public static final String SET_TITLE = "title";
	public static final String SET_LINK = "link";
	public static final String SET_IS_PROFILE = "is_profile";
	public static final String SET_FAQA = "faqs";
	public static final String SET_IS_HiDE = "status";

	public static final String ORDER_UPDATE_AT = "update_at";
	public static final String ORDER_CREATE_AT = "create_at";


	private Integer id;
	private String userName;
	private Integer lotteryAge;
	private String userPicType;
	private LotteryType lotteryType;
	private String lotteryLink;
	private String playType;
	private String prizePosttax;
	private Date prizeTime;
	private String amount;
	private Integer multiple;
	private String title;
	private String link;
	private SubjectType isProfile;
	private String faqs;
	private YesNoStatus isHide;
	private Date updateAt;
	private Date createAt;

	private String desc;
	private List<QuestionAnswerBean> questionAnswerBeanList;

	public static TopPrize convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		TopPrize topPrize = new TopPrize();
		topPrize.id = getInt(object, "id");
		topPrize.userName = getString(object, "name");
		topPrize.lotteryAge = getInt(object, "lottery_age");
		topPrize.userPicType = getString(object, "style");
		topPrize.lotteryType = LotteryType.getItem(getInt(object, "lottery_type"));
		topPrize.lotteryLink = getString(object, "lottery_link");
		topPrize.playType = getString(object, "play_type");
		topPrize.prizePosttax = getString(object, "prize_posttax");
		topPrize.prizeTime = CoreDateUtils.parseDate(("".equals(getString(object, "timeline")) || "0000-00-00 00:00:00".equals(getString(object, "timeline"))) ? null : getString(object, "timeline").substring(0, 10), CoreDateUtils.DATE);
		topPrize.amount = getString(object, "amount");
		topPrize.multiple = getInt(object, "multiple");
		topPrize.title = getString(object, "title");
		topPrize.link = getString(object, "link");
		topPrize.isProfile = SubjectType.getItem(getInt(object, "is_profile"));
		topPrize.faqs = getString(object, "faqs");
		topPrize.isHide = YesNoStatus.getItem(getInt(object, "status"));
		topPrize.updateAt = CoreDateUtils.parseDate(("".equals(getString(object, "update_at")) || "0000-00-00 00:00:00".equals(getString(object, "update_at"))) ? null : getString(object, "update_at"), CoreDateUtils.DATETIME);
		topPrize.createAt = CoreDateUtils.parseDate(("".equals(getString(object, "create_at")) || "0000-00-00 00:00:00".equals(getString(object, "create_at"))) ? null : getString(object, "create_at"), CoreDateUtils.DATETIME);
		return topPrize;
	}
	
	public static List<TopPrize> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<TopPrize> list = new ArrayList<TopPrize>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Integer getLotteryAge() {
		return lotteryAge;
	}

	public void setLotteryAge(Integer lotteryAge) {
		this.lotteryAge = lotteryAge;
	}

	public String getUserPicType() {
		return userPicType;
	}

	public void setUserPicType(String userPicType) {
		this.userPicType = userPicType;
	}

	public LotteryType getLotteryType() {
		return lotteryType;
	}

	public void setLotteryType(LotteryType lotteryType) {
		this.lotteryType = lotteryType;
	}

	public String getLotteryLink() {
		return lotteryLink;
	}

	public void setLotteryLink(String lotteryLink) {
		this.lotteryLink = lotteryLink;
	}

	public String getPlayType() {
		return playType;
	}

	public void setPlayType(String playType) {
		this.playType = playType;
	}

	public String getPrizePosttax() {
		return prizePosttax;
	}

	public void setPrizePosttax(String prizePosttax) {
		this.prizePosttax = prizePosttax;
	}

	public Date getPrizeTime() {
		return prizeTime;
	}

	public void setPrizeTime(Date prizeTime) {
		this.prizeTime = prizeTime;
	}

	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}

	public Integer getMultiple() {
		return multiple;
	}

	public void setMultiple(Integer multiple) {
		this.multiple = multiple;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public SubjectType getIsProfile() {
		return isProfile;
	}

	public void setIsProfile(SubjectType isProfile) {
		this.isProfile = isProfile;
	}

	public String getFaqs() {
		return faqs;
	}

	public void setFaqs(String faqs) {
		this.faqs = faqs;
	}



	public YesNoStatus getIsHide() {
		return isHide;
	}

	public void setIsHide(YesNoStatus isHide) {
		this.isHide = isHide;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public List<QuestionAnswerBean> getQuestionAnswerBeanList() {
		return questionAnswerBeanList;
	}

	public void setQuestionAnswerBeanList(List<QuestionAnswerBean> questionAnswerBeanList) {
		this.questionAnswerBeanList = questionAnswerBeanList;
	}

	public Date getUpdateAt() {
		return updateAt;
	}

	public void setUpdateAt(Date updateAt) {
		this.updateAt = updateAt;
	}

	public Date getCreateAt() {
		return createAt;
	}

	public void setCreateAt(Date createAt) {
		this.createAt = createAt;
	}

}
